package service.impl;

import dao.BookDao;
import dao.impl.BookDaoImpl;
import entry.Book;
import service.BookService;

import java.util.ArrayList;

public class BookServiceImpl implements BookService {
    BookDao bookDao = new BookDaoImpl();

    @Override
    public Book selectBid(int bid) {
        return bookDao.selectBid(bid);
    }

    @Override
    public boolean update(Book book) {

        return bookDao.update(book);
    }

    @Override
    public boolean addBook(Book book) {
        if (bookDao.insert(book)>0){
            return  true;
        }else {
            return false;
        }
    }

    @Override
    public ArrayList<Book> selectAll() {
        ArrayList<Book> books = bookDao.bookQuery();
        if (books!=null){
            return books;
        }else {
            return null;
        }
    }

    @Override
    public ArrayList<Book> selectBookBy(Book book) {
        ArrayList<Book> books = bookDao.selectBook(book);
        return books;

    }

    @Override
    public boolean deleteBook(int bid) {
        boolean b = bookDao.deleteBook(bid);
        return b;
    }



    public static void main(String[] args) {
        BookService bookService=new BookServiceImpl();
        //Book book=new Book(1,"大家大","adsaa","ddd",12,12.00,"2009-2-1");
        ArrayList<Book> list = bookService.selectAll();

        System.out.println(list);



    }
}
